﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphicsFramework.Drawing.Primitive
{
    class Polyline : BasePrimitive
    {

        public Polyline()
            : base(Enum.EnumDrawingType.POLYLINE, "Draw Polyline", Enum.EnumMouseClicks.POLYLINE)
        {
            Initialize(new List<Entity.Point2F>());
        }

        public Polyline(List<Entity.Point2F> points)
            : base(Enum.EnumDrawingType.POLYLINE, "Draw Polyline", Enum.EnumMouseClicks.POLYLINE)
        {
            Initialize(points);
        }

        private void Initialize(List<Entity.Point2F> points)
        {
            properties = Property.DefaultProperty.Common.Clone();
            this.points = points;

            //Update the drawing after adding points.
            UpdateDrawing();
            UpdateCenter();

        }

        public override GraphicBase Clone()
        {
            Polyline graphic = new Polyline();

            //Clone base properties
            base.Clone(graphic);

            return graphic;
        }

        public override void UpdateGuide(List<Entity.Point2F> mousedown, Entity.Point2F mousemove)
        {
            List<Entity.Point2F> points = new List<Entity.Point2F>();

            //Add mousedown to points
            foreach (Entity.Point2F point in mousedown)
            {
                points.Add(point);
            }

            //Add mousemove to points
            points.Add(mousemove);

            Initialize(points);
        }

    }
}
